package com.hzit.mmcb.core.controller.admin;


import com.hzit.common.result.PageResult;
import com.hzit.common.result.R;
import com.hzit.mmb.base.utils.JwtUtils;
import com.hzit.mmcb.core.pojo.dto.BorrowerDetailDTO;
import com.hzit.mmcb.core.pojo.entity.Borrower;
import com.hzit.mmcb.core.pojo.vo.BorrowerApprovalVO;
import com.hzit.mmcb.core.pojo.vo.BorrowerVO;
import com.hzit.mmcb.core.service.BorrowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 借款人 前端控制器
 * </p>
 *
 * @author ljh
 * @since 2024-08-27
 */
@RestController
@RequestMapping("/admin/core/borrower")
public class AdminBorrowerController {
    @Autowired
    private BorrowerService borrowerService;

    @GetMapping("/list/{page}/{limit}")
    public R list(@PathVariable Integer page,
                  @PathVariable Integer limit,
                  @RequestParam String keyword){
        PageResult<Borrower> pageModel=borrowerService.listPage(page,limit,keyword);
        return R.ok().data("pageModel",pageModel);
    }

    @GetMapping("show/{id}")
    public R show(@PathVariable Integer id){
        BorrowerDetailDTO borrowerDetailDTO=borrowerService.getDetailById(id);
        return R.ok().data("borrowerDetailVO",borrowerDetailDTO);
    }

    @PostMapping("/approval")
    public R approval(@RequestBody BorrowerApprovalVO borrowerApprovalVO){
        this.borrowerService.approval(borrowerApprovalVO);
        return R.ok().message("审批完成");
    }
}

